from django.db import models
from ckeditor_uploader.fields import RichTextUploadingField


# Create your models here.
# 食品类别
class Food_type(models.Model):
    # 食品类
    food_type = models.CharField(max_length=255)

    def __str__(self):
        return "%s" % self.food_type

# 食品表
class Eat_Food(models.Model):
    # 食品图片,RichTextUploadingField上传类型
    img = RichTextUploadingField(config_name='my_config')
    # 食品名称,models.CharField字符串类型
    food_name = models.CharField(max_length=255)
    # 库存数量,models.IntegerField数字类型
    food_number = models.IntegerField(default=100)
    # 单价,models.IntegerField数字类型
    food_money = models.FloatField(default=0)
    # 已售数量,models.IntegerField数字类型
    food_sold = models.IntegerField(default=0)

    # 一对多连接食品类
    food_type = models.ForeignKey(Food_type,on_delete=models.CASCADE)

    def __str__(self):
        return "%s" % self.food_name
